package com.tcwlkj.uuService;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.util.Log;

import com.baidu.mapapi.SDKInitializer;
import com.tcwlkj.uuService.utils.CrashHandler;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by yongliangzhao on 2017/10/9.
 */

public class MyApp extends Application {
    private static Application instance;
    private static Context mContext;//上下文


    public static synchronized Application getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(getApplicationContext(), this);

        mContext = getApplicationContext();
//        /////TODO  最简单解决  ----7.0----先测试----（已解决）///方法可行
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
//            StrictMode.setVmPolicy(builder.build());
//        }
        instance = this;
//      联网框架初始化

//        NoHttp.initialize(this);
////      开始NoHttp的调试模式, 这样就能看到请求过程和日志
//        Logger.setTag("ShanDianPaoTui");
         SDKInitializer.initialize(getApplicationContext());
//
//      极光推送
        JPushInterface.setDebugMode(true);    // 设置开启日志,发布时请关闭日志
        JPushInterface.init(this);            // 初始化 JPush
//        JPushInterface.setLatestNotificationNumber(this,1);////设置只保留最新的一条推送
//
//        ////TODo 友盟分享
//        Config.DEBUG = true;
          UMShareAPI.get(this);
////      要分享平台的APPKey和aapSceret   QQ空间 QQ 微信  微信朋友圈
          Config.DEBUG = true;
        PlatformConfig.setWeixin("wxe2d4c728a387f194", "772b5aa0b18b3dd04433911b26e3f600");
//        PlatformConfig.setQQZone("1106136911", "03TTHaVwa0yVJhSl");
////      com.wanjian.sak.LayoutManager.init(this);
//        /*开启网络广播监听*/
//        NetStateReceiver.registerNetworkStateReceiver(this);


    }

    public static Context getContext() {
        return mContext;
    }

    public void onTerminate() {
        super.onTerminate();
        System.exit(0);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Log.d("123","222");
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        Log.d("123","333");
    }




    //    @Override
//    public void onLowMemory() {
//        super.onLowMemory();
////      取消网络广播监听
//        NetStateReceiver.unRegisterNetworkStateReceiver(this);
////      杀死自己的进程
//        android.os.Process.killProcess(android.os.Process.myPid());
//    }
}
